import { RouteRecordRaw } from 'vue-router';

const routes: RouteRecordRaw[] = [
  {
    path: '/v2',
    redirect: 'v2/set-project',
    component: () => import('layouts/IndexLayout.vue'),
    children: [
      {
        path: 'login',
        component: () => import('layouts/LoginLayout.vue'),
        children: [
          {
            path: '',
            name: 'login',
            component: () => import('pages/auth/SignInPage.vue'),
          },
        ],
      },
      {
        path: 'detail',
        component: () => import('layouts/DetailLayout.vue'),
        children: [
          {
            path: '',
            name: 'runs-detail',
            component: () => import('pages/modelService/runsDetail.vue'),
          },
        ],
      },
      {
        path: '/',
        component: () => import('layouts/MainLayout.vue'),
        redirect: 'v2/set-project',
        children: [
          {
            path: 'v2/set-project',
            name: 'set-project',
            component: () => import('pages/mainPage.vue'),
            beforeEnter: (to, from, next) => {
              if (localStorage.getItem('access_token')) {
                next();
              } else {
                next({
                  path: 'v2/login',
                });
              }
            },
            meta: {
              showMenu: true,
            },
          },
          // {
          //   path: '/IndexPage',
          //   name: 'IndexPage',
          //   component: () => import('pages/IndexPage.vue'),
          //   beforeEnter: (to,from,next) =>{
          //     if( localStorage.getItem('access_token') ){
          //       next();
          //     }else {
          //       next({
          //         path: '/login'
          //       })
          //     }
          //   },
          //   meta: {
          //     showMenu: false
          //   }
          // },
          {
            path: 'v2/project',
            name: 'project',
            component: () => import('pages/project/ProjectList.vue'),
            beforeEnter: (to, from, next) => {
              if (localStorage.getItem('access_token')) {
                next();
              } else {
                next({
                  path: '/login',
                });
              }
            },
            meta: {
              showMenu: false,
            },
          },
          {
            path: 'v2/project/:project_id',
            name: 'project-detail',
            component: () => import('pages/project/ProjectDetail.vue'),
            props: true,
            meta: {
              showMenu: true,
            },
          },
          {
            path: 'v2/project/:project_id/member',
            name: 'project-member',
            component: () => import('pages/project/ProjectMember.vue'),
            props: true,
            meta: {
              showMenu: true,
            },
          },
          {
            path: 'v2/project/:project_id/configuration',
            name: 'project-configuration',
            component: () => import('pages/project/ProjectConfiguration.vue'),
            props: true,
            meta: {
              showMenu: true,
            },
          },
          {
            path: 'v2/project/:project_id/quick-start',
            name: 'quick-start',
            component: () => import('pages/DevelopingPage.vue'),
            meta: {
              showMenu: true,
            },
          },

          {
            path: 'v2/project/:project_id/datasetPage',
            name: 'dataset',
            component: () => import('pages/dataManage/datasetPage.vue'),
            props: true,
            meta: {
              showMenu: true,
              keepAlive: true,
            },
          },
          {
            path: 'v2/project/:project_id/dataset-detail',
            name: 'dataset-detail',
            component: () => import('pages/dataManage/dataSetDetail.vue'),
            props: true,
            meta: {
              showMenu: true,
            },
          },
          {
            path: 'v2/project/:project_id/create-dataset',
            name: 'dataset-create',
            component: () => import('pages/dataManage/createdataSet.vue'),
            props: true,
            meta: {
              showMenu: true,
            },
          },
          {
            path: 'v2/project/:project_id/dataset-upload',
            name: 'dataset-upload',
            component: () => import('pages/dataManage/dataSetUpload.vue'),
            props: true,
            meta: {
              showMenu: true,
            },
          },
          {
            path: 'v2/project/:project_id/data-feature',
            name: 'dataset-feature',
            component: () => import('pages/dataManage/dataFeature.vue'),
            props: true,
            meta: {
              showMenu: true,
            },
          },
          {
            path: 'v2/project/:project_id/watch-analysis',
            name: 'dataset-analysis',
            component: () => import('pages/dataManage/watchAnalysis.vue'),
            props: true,
            meta: {
              showMenu: true,
            },
          },
          {
            path: 'v2/project/:project_id/data-process',
            name: 'data-process',
            component: () => import('pages/dataManage/dataProcess.vue'),
            props: true,
            meta: {
              showMenu: true,
            },
          },
          {
            path: 'v2/project/:project_id/create-data-process',
            name: 'data-process-create',
            component: () => import('pages/dataManage/createDataProcess.vue'),
            props: true,
            meta: {
              showMenu: true,
            },
          },
          {
            path: 'v2/project/:project_id/data-label-page',
            name: 'dataAnnotations',
            component: () => import('pages/dataManage/dataLabelPage.vue'),
            props: true,
            meta: {
              showMenu: true,
            },
          },
          {
            path: 'v2/project/:project_id/data-label-detail',
            name: 'data-label-detail',
            component: () => import('pages/dataManage/dataLabelDetail.vue'),
            props: true,
            meta: {
              showMenu: true,
            },
          },
          {
            path: 'v2/project/:project_id/create-data-label-page',
            name: 'dataAnnotations-create',
            component: () => import('pages/dataManage/createDataLabelPage.vue'),
            props: true,
            meta: {
              showMenu: true,
            },
          },
          {
            path: 'v2/project/:project_id/label-operate',
            name: 'dataAnnotations-dimension',
            component: () => import('src/pages/dataManage/labelOperate.vue'),
            props: true,
            meta: {
              showMenu: true,
              activeMenu: '/project/:project_id/data-label',
            },
          },
          {
            path: 'v2/project/:project_id/featuresetPage',
            name: 'featureset',
            component: () => import('pages/dataManage/featuresetPage.vue'),
            props: true,
            meta: {
              showMenu: true,
              showBtn: true,
            },
          },
          {
            path: 'v2/project/:project_id/featureset-detail',
            name: 'featureset-detail',
            component: () => import('pages/dataManage/featureSetDetail.vue'),
            props: true,
            meta: {
              showMenu: true,
            },
          },
          {
            path: 'v2/project/:project_id/label-tag-set',
            name: 'dataAnnotations-label',
            component: () => import('pages/dataManage/labelTagSet.vue'),
            props: true,
            meta: {
              showMenu: true,
            },
          },
          // 算法管理
          {
            path: 'v2/project/:project_id/alg-manage',
            name: 'alg-manage',
            component: () => import('src/pages/algManager/algManage.vue'),
            props: true,
            meta: {
              showMenu: true,
            },
          },
          {
            path: 'v2/project/:project_id/create-alg',
            name: 'alg-manage-create',
            component: () => import('src/pages/algManager/createAlg.vue'),
            props: true,
            meta: {
              showMenu: true,
            },
          },
          {
            path: 'v2/project/:project_id/alg-detail',
            name: 'alg-manage-detail',
            component: () => import('src/pages/algManager/algDetail.vue'),
            props: true,
            meta: {
              showMenu: true,
            },
          },
          // 模型服务
          {
            path: 'v2/project/:project_id/model-manage',
            name: 'model-manage',
            component: () => import('src/pages/modelService/modelManage.vue'),
            props: true,
            meta: {
              showMenu: true,
            },
          },
          {
            path: 'v2/project/:project_id/create-model-manage',
            name: 'model-manage-create',
            component: () => import('src/pages/modelService/createModelManage.vue'),
            props: true,
            meta: {
              showMenu: true,
            },
          },
          {
            path: 'v2/project/:project_id/submit-model-manage',
            name: 'model-manage-submit',
            component: () =>
              import('src/pages/modelService/submitModelManage.vue'),
            props: true,
            meta: {
              showMenu: true,
            },
          },
          {
            path: 'v2/project/:project_id/model-app',
            name: 'model-app',
            component: () => import('src/pages/modelService/modelApp.vue'),
            props: true,
            meta: {
              showMenu: true,
            },
          },
          {
            path: 'v2/project/:project_id/create-model-app',
            name: 'model-app-create',
            component: () =>
              import('src/pages/modelService/createModelApp.vue'),
            props: true,
            meta: {
              showMenu: true,
            },
          },
          {
            path: 'v2/project/:project_id/model-app-detail',
            name: 'model-app-detail',
            component: () => import('src/pages/modelService/modelAppDetail.vue'),
            props: true,
            meta: {
              showMenu: true,
            },
          },
          {
            path: 'v2/project/:project_id/model-app-compare',
            name: 'model-app-compare',
            component: () => import('src/pages/modelService/modelAppCompare.vue'),
            props: true,
            meta: {
              showMenu: true,
            },
          },
          {
            path: 'v2/project/:project_id/model-app-detail-version',
            name: 'model-app-detail-version',
            component: () => import('src/pages/modelService/mAppDetailVersion.vue'),
            props: true,
            meta: {
              showMenu: true,
            },
          },
          {
            path: 'v2/project/:project_id/model-add-version',
            name: 'model-add-version',
            component: () => import('pages/modelService/modelAddVersion/addVersionIndex.vue'),
            props: true,
            meta: {
              showMenu: true,
            },
          },
          {
            path: 'v2/project/:project_id/assessment-report',
            name: 'assessment-report',
            component: () => import('pages/modelService/assessmentReport.vue'),
            props: true,
            meta: {
              showMenu: true,
            },
          },
          {
            path: 'v2/project/:project_id/metric_history',
            name: 'metric_history',
            component: () => import('pages/modelService/metricHistory.vue'),
            props: true,
            meta: {
              showMenu: true,
            },
          },
          {
            path: 'v2/project/:project_id/model-deploy',
            name: 'model-deploy',
            component: () => import('src/pages/modelService/modelDeploy.vue'),
            props: true,
            meta: {
              showMenu: true,
            },
          },
          {
            path: 'v2/project/:project_id/create-model-deploy',
            name: 'model-deploy-create',
            component: () => import('src/pages/modelService/createModelDeploy.vue'),
            props: true,
            meta: {
              showMenu: true,
            },
          },
          {
            path: 'v2/project/:project_id/deploy-detail',
            name: 'model-deploy-detail',
            component: () => import('pages/modelService/deployDetail/deployIndex.vue'),
            props: true,
            meta: {
              showMenu: true,
            },
          },
          {
            path: 'v2/userManage',
            name: 'system-user',
            component: () => import('pages/systemManage/userManage.vue'),
            props: true,
            meta: {
              showMenu: true,
            },
          },
          {
            path: 'v2/addSystemUser',
            name: 'system-addSystemUser',
            component: () => import('pages/systemManage/addSystemUser.vue'),
            props: true,
            meta: {
              showMenu: true,
            },
          },
          {
            path: 'v2/menuManage',
            name: 'system-menu',
            component: () => import('pages/systemManage/menuManage.vue'),
            props: true,
            meta: {
              showMenu: true,
            },
          },
          {
            path: 'v2/roleManage',
            name: 'system-role',
            component: () => import('pages/systemManage/roleManage.vue'),
            props: true,
            meta: {
              showMenu: true,
            },
          },
          {
            path: 'v2/dailyRecordManage',
            name: 'system-dailyRecord',
            component: () => import('pages/systemManage/dailyRecordManage.vue'),
            props: true,
            meta: {
              showMenu: true,
            },
          },
          // 设计器模块
          {
            path: 'v2/project/:project_id/designer-tool',
            name: 'designer-tool',
            component: () => import('pages/designerTool/designerTool.vue'),
            props: true,
            meta: {
              showMenu: true,
            },
          },
          {
            path: 'v2/project/:project_id/designer-detail',
            name: 'designer-tool-detail',
            component: () => import('pages/designerTool/designerDetail.vue'),
            props: true,
            meta: {
              showMenu: true,
            },
          },
          {
            path: 'v2/project/:project_id/designer-experiments',
            name: 'designer-tool-experiments',
            component: () => import('pages/designerTool/designerExperiments.vue'),
            props: true,
            meta: {
              showMenu: true
            }
          },
          {
            path: 'v2/project/:project_id/operator-manager',
            name: 'designer-manager',
            component: () =>
              import('pages/designerTool/workflow/operatorManager.vue'),
            props: true,
            meta: {
              showMenu: true,
            },
          },
          // 公开市场
          {
            path: 'v2/project/:project_id/public-market',
            name: 'public-market',
            component: () => import('pages/publicMarket/marketIndex.vue'),
            props: true,
            meta: {
              showMenu: true,
            },
          },
          // 快速入门
          {
            path: 'v2/project/:project_id/quick-start',
            name: 'quick-start',
            component: () =>
              import('pages/quickStart/indexPage.vue'),
            props: true,
            meta: {
              showMenu: true,
            },
          },
        ],
      },
    ],
  },
  // 设计器画布详情
  {
    path: '/v2/canvas-index',
    name: 'canvas-index',
    component: () => import('pages/designerTool/canvas/canvasIndex.vue'),
    props: true,
    meta: {
      showMenu: true,
    },
  },
  {
    path: '/:catchAll(.*)*',
    component: () => import('pages/ErrorNotFound.vue'),
  },
  {
    path: '/v2/model-error-deta',
    name: 'errorData',
    component: () => import('src/pages/modelService/errorData.vue'),
    props: true,
    meta: {
      showMenu: false,
    },
  },
];

export default routes;
